Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

[ASTS] Fix: Update getTimestampRangeRecord to return empty when record not present #7439

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mdaudali
Copy link
Contributor

General

Before this PR:
Part 1 (of ~3): The background shard progress updater assumes that buckets without progress are unstarted. This is incorrect, because 1) we delete progress when the bucket is complete, but separately 2) we delete progress right after finding completed buckets, and so if we crashed after deleting progress but before updating the starting bucket (and assuming the foreground task removes the sweepable bucket entry too), then we'd never make progress past the bucket we crashed on.

Instead, we need a new method to determine when a bucket is completed, as shown in the draft #7424.

After this PR:
Updates the guarantees around getTimestampRangeRecord. The signature now reflects the fact that a record may not be present in certain circumstances (open buckets) and that this is not an exceptional event.

We will use this (will exist after this PR) + progress (already exists) + whether a sweepable bucket entry exists (method coming in another PR) to determine the status of a bucket.

==COMMIT_MSG==
==COMMIT_MSG==

Priority:
P2
Concerns / possible downsides (what feedback would you like?):
The ShardProgressUpdater is still broken. I'll fix it in the final PR.
Is documentation needed?:

Compatibility

Does this PR create any API breaks (e.g. at the Java or HTTP layers) - if so, do we have compatibility?:
No
Does this PR change the persisted format of any data - if so, do we have forward and backward compatibility?:
No
The code in this PR may be part of a blue-green deploy. Can upgrades from previous versions safely coexist? (Consider restarts of blue or green nodes.):
Yes
Does this PR rely on statements being true about other products at a deployment - if so, do we have correct product dependencies on these products (or other ways of verifying that these statements are true)?:
No
Does this PR need a schema migration?
No

Testing and Correctness

What, if any, assumptions are made about the current state of the world? If they change over time, how will we find out?:
That ASTS is not being used outside of one test env
What was existing testing like? What have you done to improve it?:
Updated the tests
If this PR contains complex concurrent or asynchronous code, is it correct? The onus is on the PR writer to demonstrate this.:
N/A
If this PR involves acquiring locks or other shared resources, how do we ensure that these are always released?:
N/A

Execution

How would I tell this PR works in production? (Metrics, logs, etc.):
Final PR

Scale

Would this PR be expected to pose a risk at scale? Think of the shopping product at our largest stack.:
N/A
Would this PR be expected to perform a large number of database calls, and/or expensive database calls (e.g., row range scans, concurrent CAS)?:
N/A
Would this PR ever, with time and scale, become the wrong thing to do - and if so, how would we know that we need to do something differently?:
N/A

Development Process

Where should we start reviewing?:
DSABS
If this PR is in excess of 500 lines excluding versions lock-files, why does it not make sense to split it?:

Please tag any other people who should be aware of this PR:
@jeremyk-91
@raiju

@changelog-app
Copy link

changelog-app bot commented Nov 12, 2024

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

[ASTS] Fix: Update getTimestampRangeRecord to return empty when record not present

Check the box to generate changelog(s)

  • Generate changelog entry

@mdaudali mdaudali force-pushed the mdaudali/11-12-_asts_fix_update_gettimestamprangerecord_to_return_empty_when_record_not_present branch from 1273547 to 26515f9 Compare November 12, 2024 15:16
Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this API, but had a question on the guarantee we're aiming for

@@ -120,17 +119,16 @@ private BucketProbeResult findCompletedBuckets(ShardAndStrategy shardAndStrategy
throw new SafeIllegalStateException("Didn't expect to get here");
}

// TODO(mdaudali): This method is still incorrect (a record does not exist for an open bucket, not just pre-init
// bucket 0). A follow up PR will address this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* Returns the {@link TimestampRange} for the given bucket identifier, throwing a
* {@link java.util.NoSuchElementException} if one is not present.
* Returns a {@link TimestampRange} for the given bucket identifier, if one exists. Iff a bucket is closed, then
* the corresponding record will be present. (If the bucket is open, no record will be present.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't atomic though right? The bucket writer, in order, does the following:

  1. writes closed buckets to the buckets table
  2. writes the bucket record
  3. sets the state machine to be ready going in the next state

So if we happen to launch this query between steps 1 and 2, then there could be a closed bucket with no record in the bucket records table, unless I've misunderstood something. It's more "if record present, bucket definitively closed - if record not present, bucket could be open or closed".

For what it's worth I think your prototype in #7424 handles this acceptably, though I'm not fully certain if the logging there is always correct - it is OK to end the bucket probe even if the bucket was closed (and we're only doing it for an edge case where transitioning to ready keeps failing).

@mdaudali mdaudali requested a review from jeremyk-91 November 13, 2024 17:51
@mdaudali mdaudali force-pushed the mdaudali/11-12-_asts_fix_update_gettimestamprangerecord_to_return_empty_when_record_not_present branch from 26515f9 to f7f270b Compare November 13, 2024 17:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants